{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Downloading data from https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz\n",
      "170500096/170498071 [==============================] - 50s 0us/step\n"
     ]
    }
   ],
   "source": [
    "import tensorflow as tf\n",
    "cifar10 = tf.keras.datasets.cifar10\n",
    "(x_train,y_train),(x_test,y_test) = cifar10.load_data()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(50000, 32, 32, 3)"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x_train.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(50000, 1)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_train.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(10000, 32, 32, 3)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x_test.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(10000, 1)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_test.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x2425be5f988>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPsAAAD5CAYAAADhukOtAAAAOXRFWH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FYBXeukHgO+h83awgc5nr8+j0zPvWQBvAPi/AIb3yY//DuAUgJPoBNtED/z4MDpv0U8CeKn77xO9XpMIP3q6JgDuRaeI60l0/rD822uu2V8AOAvgzwFk38tx9Q06IWJC3DfohIgNCnYhYoKCXYiYoGAXIiYo2IWICQp2IWKCgl2ImKBgFyIm/H9Xl6noupYWMgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "plt.imshow(x_train[6])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "x_train = x_train.astype(\"float32\")/255.0\n",
    "x_test = x_test.astype(\"float32\")/255.0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "model = tf.keras.models.Sequential()\n",
    "model.add(tf.keras.layers.Conv2D(filters = 32,\n",
    "                                input_shape = (32,32,3),\n",
    "                                kernel_size = (3,3),\n",
    "                                activation = \"relu\",\n",
    "                                padding = \"same\"))\n",
    "model.add(tf.keras.layers.Dropout(rate = 0.3))\n",
    "model.add(tf.keras.layers.MaxPool2D(pool_size = (2,2)))\n",
    "model.add(tf.keras.layers.Conv2D(filters = 64,\n",
    "                                activation = \"relu\",\n",
    "                                kernel_size = (3,3),\n",
    "                                padding = \"same\"))\n",
    "model.add(tf.keras.layers.Dropout(rate = 0.3))\n",
    "model.add(tf.keras.layers.MaxPool2D(pool_size = (2,2)))\n",
    "model.add(tf.keras.layers.Flatten())\n",
    "model.add(tf.keras.layers.Dense(units = 128,\n",
    "                               kernel_initializer = \"normal\",\n",
    "                               use_bias = True,\n",
    "                               bias_initializer = \"zeros\",\n",
    "                               activation = \"sigmoid\"))\n",
    "model.add(tf.keras.layers.Dense(units = 10,\n",
    "                               activation = \"softmax\"))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 1/20\n",
      "400/400 - 24s - loss: 1.5940 - accuracy: 0.4289 - val_loss: 1.4377 - val_accuracy: 0.5038\n",
      "Epoch 2/20\n",
      "400/400 - 24s - loss: 1.2164 - accuracy: 0.5704 - val_loss: 1.1780 - val_accuracy: 0.6116\n",
      "Epoch 3/20\n",
      "400/400 - 25s - loss: 1.0528 - accuracy: 0.6305 - val_loss: 1.0615 - val_accuracy: 0.6413\n",
      "Epoch 4/20\n",
      "400/400 - 25s - loss: 0.9476 - accuracy: 0.6689 - val_loss: 1.0067 - val_accuracy: 0.6552\n",
      "Epoch 5/20\n",
      "400/400 - 25s - loss: 0.8684 - accuracy: 0.6978 - val_loss: 0.9370 - val_accuracy: 0.6806\n",
      "Epoch 6/20\n",
      "400/400 - 25s - loss: 0.8098 - accuracy: 0.7179 - val_loss: 0.9143 - val_accuracy: 0.6850\n",
      "Epoch 7/20\n",
      "400/400 - 25s - loss: 0.7537 - accuracy: 0.7377 - val_loss: 0.8966 - val_accuracy: 0.6873\n",
      "Epoch 8/20\n",
      "400/400 - 25s - loss: 0.7040 - accuracy: 0.7570 - val_loss: 0.8569 - val_accuracy: 0.7037\n",
      "Epoch 9/20\n",
      "400/400 - 25s - loss: 0.6553 - accuracy: 0.7746 - val_loss: 0.8356 - val_accuracy: 0.7100\n",
      "Epoch 10/20\n",
      "400/400 - 25s - loss: 0.6052 - accuracy: 0.7934 - val_loss: 0.8277 - val_accuracy: 0.7175\n",
      "Epoch 11/20\n",
      "400/400 - 25s - loss: 0.5621 - accuracy: 0.8107 - val_loss: 0.8295 - val_accuracy: 0.7165\n",
      "Epoch 12/20\n",
      "400/400 - 25s - loss: 0.5274 - accuracy: 0.8215 - val_loss: 0.8357 - val_accuracy: 0.7120\n",
      "Epoch 13/20\n",
      "400/400 - 25s - loss: 0.4828 - accuracy: 0.8376 - val_loss: 0.8064 - val_accuracy: 0.7215\n",
      "Epoch 14/20\n",
      "400/400 - 25s - loss: 0.4454 - accuracy: 0.8518 - val_loss: 0.8219 - val_accuracy: 0.7204\n",
      "Epoch 15/20\n",
      "400/400 - 25s - loss: 0.4111 - accuracy: 0.8654 - val_loss: 0.8145 - val_accuracy: 0.7260\n",
      "Epoch 16/20\n",
      "400/400 - 25s - loss: 0.3817 - accuracy: 0.8750 - val_loss: 0.8262 - val_accuracy: 0.7222\n",
      "Epoch 17/20\n",
      "400/400 - 25s - loss: 0.3483 - accuracy: 0.8874 - val_loss: 0.8486 - val_accuracy: 0.7179\n",
      "Epoch 18/20\n",
      "400/400 - 25s - loss: 0.3194 - accuracy: 0.8982 - val_loss: 0.8783 - val_accuracy: 0.7106\n",
      "Epoch 19/20\n",
      "400/400 - 26s - loss: 0.2964 - accuracy: 0.9062 - val_loss: 0.8822 - val_accuracy: 0.7169\n",
      "Epoch 20/20\n",
      "400/400 - 26s - loss: 0.2685 - accuracy: 0.9171 - val_loss: 0.8742 - val_accuracy: 0.7193\n"
     ]
    }
   ],
   "source": [
    "train_epochs = 20\n",
    "batch_size = 100\n",
    "\n",
    "model.compile(optimizer = \"adam\",\n",
    "             loss=\"sparse_categorical_crossentropy\",\n",
    "             metrics = [\"accuracy\"])\n",
    "train_history = model.fit(x = x_train, y = y_train,validation_split=0.2,\n",
    "                         verbose=2,epochs = train_epochs,batch_size = batch_size)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
